package com.exposit.books.domain;


import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table (name="orders")
public class Order {
	
	private Long id;
	private Buyer buyer;
	private Book book;
	private Long count;
	private String address;
	private String payment;
	private Long status;
	private Date date;
	private Long priceOfOneBook;
	private PreOrders preOrders;
	
	public Order(){}
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "buyer_id", nullable = false)
	public Buyer getBuyer() {
		return buyer;
	}
	public void setBuyer(Buyer buyer) {
		this.buyer = buyer;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "book_id", nullable = false)
	public Book getBook() {
		return book;
	}
	public void setBook(Book book) {
		this.book = book;
	}
	
	public Long getCount() {
		return count;
	}
	public void setCount(Long count) {
		this.count = count;
	}
	
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	
	public String getPayment() {
		return payment;
	}
	public void setPayment(String payment) {
		this.payment = payment;
	}
	
	@Temporal(value=TemporalType.DATE)
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	
	
	public Long getStatus() {
		return status;
	}
	public void setStatus(Long status) {
		this.status = status;
	}
	
	
	public Long getPriceOfOneBook() {
		return priceOfOneBook;
	}
	public void setPriceOfOneBook(Long priceOfOneBook) {
		this.priceOfOneBook = priceOfOneBook;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "preorders_id", nullable = false)
	public PreOrders getPreOrders() {
		return preOrders;
	}

	public void setPreOrders(PreOrders preOrders) {
		this.preOrders = preOrders;
	}
}
